﻿using Com.JunCaiSoft.ConstructionCashFlow.Dao;
using Com.JunCaiSoft.ConstructionCashFlow.IDao;
using Com.JunCaiSoft.DBContext;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Com.JunCaiSoft.ConstructionCashFlow
{
    public static class ConstructionCashFlowServiceCollectionExtension
    {
        public static IServiceCollection AddConstructionCashFlow(this IServiceCollection services)
        {
            //添加银行相关注入
            services.TryAddSingleton<IBankDao>(new BankDao(services.BuildServiceProvider().GetService<MSSQLDbContext>()));
            //添加项目相关注入
            services.TryAddSingleton<IProjectDao>(new ProjectDao(services.BuildServiceProvider().GetService<MSSQLDbContext>()));
            //添加资金流相关注入
            services.TryAddSingleton<ICashFlowDao>(new CashFlowDao(services.BuildServiceProvider().GetService<MSSQLDbContext>()));
            //添加银行类型相关注入
            services.TryAddSingleton<IBankTypeDao>(new BankTypeDao(services.BuildServiceProvider().GetService<MSSQLDbContext>()));
            //添加款项类型相关注入
            services.TryAddSingleton<IFundsTypeDao>(new FundsTypeDao(services.BuildServiceProvider().GetService<MSSQLDbContext>()));
            //添加工程类型相关注入
            services.TryAddSingleton<IProjectTypeDao>(new ProjectTypeDao(services.BuildServiceProvider().GetService<MSSQLDbContext>()));

            return services;
        }
    }
}
